<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>ChessBoard</title>
</head>

<body>
    <script>
            // createing chess table
            chess = document.createElement('table');
            chess.border = "5";
            document.getElementsByTagName('body')[0].appendChild(chess);

            for (var i = 1; i <= 8; i++){
                // creating row 
                var row = chess.insertRow(i-1);
                for(var j = 1; j <= 8; j++){
                    // creating cells 
                    if ((i%2!=0 && j%2==0)||(i%2==0 && j%2!=0)) {
                        var cell = row.insertCell(j-1);
                        cell.style.backgroundColor = 'black';
                        cell.style.width = cell.style.height = '50px';
                    }
                    else  {
                        var cell = row.insertCell(j-1);
                        cell.style.backgroundColor = 'white';
                        cell.style.width = cell.style.height = '50px';
                    }
                }
            }
    </script>
</body>
</html>